package WaiBao;

import java.util.Arrays;

public class ZhaoSiLin {
    public static void main(String[] args) {
        String[] name = {"李阳阳(团支书)", "李志远(副班长)", "小李(学习委员)", "王劲松(体育委员)", "王碧甜", "李值", "李樱桃", "王婷婷", "王志阳", "王大锤", "李大彪", "王胖子",
                "肖战", "贾探春", "灵代玉", "王皓", "韩星", "刘诗诗", "吴奇隆", "杜甫", "李贺", "关晓彤", "欧阳修", "欧阳楠楠", "程咬金", "张浩然", "蒙恬", "王宝强",
                "林俊杰", "赵思林(班长)"};//考生本人:赵思林(班长)
        int[] age = {20, 21, 18, 20, 19, 20, 21, 21, 19, 21, 18, 18, 22, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 18, 21, 20, 19};//考试年龄：19

        double[] zhiyao1 = {78, 88, 80, 94, 88, 69, 78, 59, 60, 70, 91, 87, 75, 75, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 81, 69, 96};
        double[] zhiyao2 = {64, 84, 70, 64, 68, 97, 88, 95, 90, 94, 95, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 74, 74, 95};
        double[] zhiyao3 = {88, 99, 79, 91, 90, 99, 69, 83, 80, 60, 73, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 88, 74, 97};


        double wuli1;//代表每个学生的总分
        double wuli2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            wuli1 = zhiyao1[i] + zhiyao2[i] +zhiyao3[i];
//            wuli2 = (wuli1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + wuli1);
//            System.out.println(name[i] + "的平均分为:" +wuli2);
//        }

        double hauxue1 = 0,hauxue2 = 0;
        double[] yingyu = new double[30];
//        for (int i = 0; i < 30; i++) {
//            hauxue1= zhiyao1[i] +zhiyao2[i] +zhiyao3[i];
//            hauxue2 = (hauxue1 * 1.0) / 3;
//            yingyu[i] = hauxue2;
//        }
//
//        for (int i = 0; i < yingyu.length - 1; i++) {
//            for (int j = 0; j < yingyu.length - i - 1; j++) {
//                if (yingyu[j] < yingyu[j + 1]) {
//                    double temp = yingyu[j];
//                    yingyu[j] = yingyu[j + 1];
//                    yingyu[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(yingyu[i]);
//        }


        double wenjian1 = 0, wenjian2 = 0, wenjian3 = 0;//计算每门课的平均分
        double chaunshu1 = 0,chaunshu2 = 0,chaunshu3 = 0;//计算每门课标准差
        double zhushou1 = 0, zhushou2 = 0, zhushou3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < zhiyao1.length; i++) {
            sum2+=zhiyao1[i];
        }
        wenjian1 = (sum2*1.0)/30;
        System.out.println("农业设施及环境调控的平均分为:"+wenjian1);
        double Sum = 0;
        for (int i = 0; i < zhiyao2.length; i++) {
            Sum+=zhiyao2[i];
        }
        wenjian2 = (Sum*1.0)/30;
        System.out.println("农业设施设计与制造的班级平均分为:"+wenjian2);
        double sum = 0;
        for (int i = 0; i <zhiyao3.length; i++) {
            sum+=zhiyao3[i];
        }
        wenjian3 = (sum*1.0)/30;
        System.out.println("园艺植物设施栽培学的班级平均分为:"+wenjian3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < zhiyao1.length; i++) {
            c1+= (zhiyao1[i] - wenjian1)*(zhiyao1[i] - wenjian1);
        }
        chaunshu1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:"+chaunshu1);

        for (int i = 0; i <zhiyao2.length; i++) {
            c2+= (zhiyao2[i] - wenjian2)*(zhiyao2[i] -wenjian2);
        }
        chaunshu2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与制造的班级标准差为:"+chaunshu2);

        for (int i = 0; i <zhiyao3.length; i++) {
            c3+= (zhiyao3[i] - wenjian3)*(zhiyao3[i] - wenjian3);
        }
        chaunshu3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的班级标准差为:"+chaunshu3);
////
        Arrays.sort(zhiyao1);
        Arrays.sort(zhiyao2);
        Arrays.sort(zhiyao3);
        zhushou1 =( zhiyao1[15]+zhiyao1[14])*1.0/2;
        zhushou2 =( zhiyao2[15]+zhiyao2[14])*1.0/2;
        zhushou3 =( zhiyao3[15]+zhiyao3[14])*1.0/2;
        System.out.println("农业设施及环境调控的中位数为:"+zhushou1);
        System.out.println("农业设施设计与制造的中位数为:"+zhushou2);
        System.out.println("园艺植物设施栽培学的中位数为:"+zhushou3);



    }
}
